/**
 * 
 */
package com.hfjyz.examination.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.hfjyz.examination.command.QuestionEditCommand;

/**
 *
 */
public class QuestionEditValidator implements Validator {

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public boolean supports(Class clazz) {
		return clazz.isAssignableFrom(QuestionEditCommand.class);
	}

	@Override
	public void validate(Object target, Errors errors) {

		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "qtype",
				"error.question.qtype", "please select question qtype.");

		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "content",
				"error.question.content", "please input question content.");

		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "category",
				"error.question.category", "please select question category.");

		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "qkey",
				"error.question.qkey", "please input question qkey.");

	}

}
